Skip to content

fix(cli): folded paste content was invisible to the model#5347

Merged
SivanCola merged 2 commits into
esengine:main-v2from
liugh-dev:fix/cli-paste-memory-compiler-source-event
Jun 26, 2026
Merged

fix(cli): folded paste content was invisible to the model#5347
SivanCola merged 2 commits into
esengine:main-v2from
liugh-dev:fix/cli-paste-memory-compiler-source-event

Conversation

@liugh-dev

Copy link
Copy Markdown

Summary

A folded multi-line paste ([Pasted text #N · M lines]) was never seen by the model — only the placeholder label was. The CLI passed the folded label (the un-expanded line) as the controller's raw value. The Memory v5 compiler (enabled by default) takes raw as the source_event of its execution contract, and that contract replaces the whole user turn — so the model's only view of the paste became the label, with the actual content lost.

Verification

Copy multi-line text and paste into the input erea, then ask the agent how many lines it can see. If it can't see any pasted text, the bug exists.

Cache impact

Cache-impact: TODO
Cache-guard: TODO
System-prompt-review: N/A

For cache-sensitive changes, fill these lines before requesting review:

  • Cache-impact: none, low, medium, or high, plus the reason.
  • Cache-guard: the focused guard test/command added or run, or why an existing guard covers the change.
  • System-prompt-review: required reviewer/approval note when provider-visible system prompt, memory prefix, output style, or skill index behavior changes.

A folded multi-line paste ([Pasted text #N · M lines]) was never seen by
the model — only the placeholder label was. The CLI passed the folded
label (the un-expanded `line`) as the controller's `raw` value. The Memory
v5 compiler (enabled by default) takes `raw` as the source_event of its
execution contract, and that contract replaces the whole user turn — so
the model's only view of the paste became the label, with the actual
content lost.

The Desktop path already passes the expanded text as `raw`; only the CLI
passed the label. Pass the expanded content (sentLine / msg.display) as
`raw` in both the non-refs and @-refs submit paths, matching Desktop.
`raw` still excludes resolved @-reference payloads (per the existing
TestRunCompilesMemorySourceFromUnexpandedContext intent) — it now carries
the expanded paste block but not inline file contents.

Add TestPasteFoldExpandOnSubmit, which asserts the memory-compiler
source_event holds the expanded paste (it fails before the fix:
source_event is only "[Pasted text esengine#1 · 11 lines]").

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Jun 26, 2026

@SivanCola SivanCola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. This is a well-scoped fix for the folded-paste regression.

The important part is that the controller raw value now carries the expanded paste text instead of the visible folded placeholder, so Memory v5's source_event no longer loses the actual pasted content. The added regression captures both the runner input and the memory-compiler source input, which is the right contract to pin down here.

Cache impact: low. This changes the dynamic user-turn source text for pasted content only; it does not alter the stable provider-visible prefix, tool schemas, system prompt, or request serialization.

Verified:

  • go test ./internal/cli -count=1 passed with this PR stacked alongside the current non-draft TUI changes that touch the same file.
  • The PR cherry-picks cleanly onto the latest main-v2 together with #5349 and #5378.

Wait for the controller TurnDone event before reading the recording runner output. This gives the async send path a real happens-before edge under go test -race instead of relying on a fixed sleep.
@SivanCola

Copy link
Copy Markdown
Collaborator

Pushed f6b7b42 to fix the failing race check.

Root cause: TestPasteFoldExpandOnSubmit waited with a fixed sleep and then read the recording runner output while the controller goroutine could still be writing it under go test -race.

Fix: the test now wires a test event sink and waits for event.TurnDone before reading the recorded runner input. Runtime behavior is unchanged; this only gives the async test path a real happens-before edge.

Verified:

  • go test -race ./internal/cli -run TestPasteFoldExpandOnSubmit -count=20
  • go test -race ./internal/cli -count=1
  • go test ./internal/cli -count=1
  • go test -race ./...
  • Clean merge check against latest main-v2, plus go test -race ./internal/cli -count=1

@SivanCola SivanCola merged commit 5d76514 into esengine:main-v2 Jun 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants